﻿namespace E6BTest
{
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using PocketE6B.Engine;
    
    /// <summary>
    /// This class provides a testing framework for the E6B engine.
    /// </summary>
    public abstract class E6BTests
    {
        /// <summary>Gets or sets the E6B instance to use for testing.</summary>
        protected static E6B Computer { get; set; }

        /// <summary>Gets or sets the wind speed, in knots.</summary>
        protected static double WindSpeed { get; set; }

        /// <summary>Gets or sets the true airspeed, in knots.</summary>
        protected static double TrueAirspeed { get; set; }

        /// <summary>Gets or sets the wind direction, in degrees.</summary>
        protected static double WindDirection { get; set; }

        /// <summary>Gets or sets the course, in degrees.</summary>
        protected static double Course { get; set; }

        /// <summary>
        /// Configures the test suite's E6B with the speeds and angles used for
        /// each test.
        /// </summary>
        /// <param name="context">The test context.</param>
        public static void SuiteSetup(TestContext context)
        {
            // configure the E6B
            Computer = new E6B();
            ConfigureE6B();
        }

        /// <summary>
        /// Cleans up any resources used by the E6B.
        /// </summary>
        public static void SuiteCleanup()
        {
        }

        /// <summary>
        /// Updates the E6B instance to use the current test data.
        /// </summary>
        protected static void ConfigureE6B()
        {
            Computer.TrueAirspeed = TrueAirspeed;
            Computer.WindSpeed = WindSpeed;
            Computer.WindDirection = WindDirection;
            Computer.Course = Course;
        }
    }
}